import { MeasureType } from "@/constants/enums/logisticsTemplate";
import request from "@/utils/request";

import request2 from "@/utils/request2";

export async function queryLogisticsTemplate(params: PaginationParams & {measureType?: MeasureType}) {
  return request2<LogisticsTemplate[]>(`/api/mall/manage/logistics/template/${params.pageSize}/${params.pageNum}`, {
    method: 'GET',
    data: {
      measureType: params.measureType,
    },
  })
}

export async function saveLogisticsTemplate(params: Partial<LogisticsTemplate>) {
  return request2('/api/mall/manage/logistics/template', {
    method: 'POST',
    data: params,
  })
}

export async function removeLogisticsTemplate(params: {templateId: string}) {
  return request2(`/api/mall/manage/logistics/template/${params.templateId}`, {
    method: 'DELETE',
  })
}

export async function removeLogisticsTemplateArea(params: {templateId: string, templateAreaId: string}) {
  return request2(`/api/mall/manage/logistics/template/${params.templateId}/${params.templateAreaId}`, {
    method: 'DELETE',
  })
}